package com.wgts.wgts.mvp.presenter.imp;

import com.wgts.wgts.mvp.model.IWgtsResetPasswordActivityModel;
import com.wgts.wgts.mvp.presenter.IWgtsResetPasswordActivityPresenter;
import com.wgts.wgts.mvp.view.IWgtsResetPasswordActivityView;
import com.wgts.wgts.netmodle.HttpResultSubscriber;
import com.wgts.wgts.netmodle.resp.CurrentEntity;
import com.wgts.wgts.react.MD5Util;

/*
 *   author:handsome
 *   data:2018/11/717:34
 *   packeage:${PAKAGE_NAME}
 *
 */public class WgtsResetPasswordActivityPresenter implements IWgtsResetPasswordActivityPresenter {
     private IWgtsResetPasswordActivityView view;
     private IWgtsResetPasswordActivityModel model;

    public WgtsResetPasswordActivityPresenter(IWgtsResetPasswordActivityView view, IWgtsResetPasswordActivityModel model) {
        this.view = view;
        this.model = model;
    }


    @Override
    public void resetPassword(String password, String confirmPassword, String smsCode, String phone) {

        password = MD5Util.encrypt(password);
        confirmPassword = MD5Util.encrypt(confirmPassword);

        model.resetPassword(password, confirmPassword, smsCode, phone, new HttpResultSubscriber<CurrentEntity>() {
            @Override
            public void onSuccess(CurrentEntity currentEntity) {
                view.resetPassword();
            }

            @Override
            public void _onError(int status, String msg) {
                view.onError(status, msg);
            }
        });
    }
}
